package com.wzy.controller;

import com.wzy.dao.UserDao;
import com.wzy.entity.User;
import com.wzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public List<User> index()
    {
        List<User> all=userService.find();
        return all;
    }
    @PostMapping("/add")
    public Integer save(@RequestBody User user)
    {
       return  userService.save(user);
    }
    @PostMapping("/update")
    public Integer update(@RequestBody User user)
    {
        return  userService.save(user);
    }
    @DeleteMapping("/delete")
    public Integer delete(@RequestBody User user)
    {
        return  userService.delete(user);
    }
}
